// event lib
var events = require('events');

// event emitter
var emitter = new events.EventEmitter();

// create event program
var connHandler = function connected() {
	console.log('connected');
        // send event
	emitter.emit('data_received');
}

// bind event
emitter.on('connection', connHandler);

// event handler
emitter.on('data_received', function() {
	console.log('data received successed');
});

// send event
emitter.emit('connection');

console.log('program end');
